package com.hyq.market.base;

import android.support.annotation.Nullable;

import com.hannesdorfmann.mosby.mvp.MvpView;

import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/7/19 0019.
 */

public abstract class AbsPresenter<V extends MvpView> implements IPersenter<V> ,NetCallback{
    public IMode iMode;
    private WeakReference<V> viewRef;

    @Override public void attachView(V view) {
        viewRef = new WeakReference<V>(view);
    }

    /**
     * Get the attached view. You should always call {@link #isViewAttached()} to check if the view
     * is
     * attached to avoid NullPointerExceptions.
     *
     * @return <code>null</code>, if view is not attached, otherwise the concrete view instance
     */
    @Nullable public V getView() {
        return viewRef == null ? null : viewRef.get();
    }

    /**
     * Checks if a view is attached to this presenter. You should always call this method before
     * calling {@link #getView()} to get the view instance.
     */
    public boolean isViewAttached() {
        return viewRef != null && viewRef.get() != null;
    }

    @Override public void detachView(boolean retainInstance) {
        if (viewRef != null) {
            viewRef.clear();
            viewRef = null;
        }
    }


    @Override
    public <T> void netSucceed(T t, int code) {

    }

    @Override
    public <T> void netSucceed(List<T> t, int code) {

    }

    @Override
    public <T> void netFailed(T t, int code) {

    }

    @Override
    public <T> void onCancelled(T cex, int code) {

    }

   public abstract  <T>  void getData(T t);




}
